import React, { PureComponent } from 'react';
import "./index.less"
import "../../Common.less"
class tab extends PureComponent {
    constructor(props) {
        super(props);
        this.state={
           index:0
        }
        this.onClick=this.onClick.bind(this)
    }
    onClick(e,item,index){
        e.preventDefault();
        if(this.props.onClick){
            this.props.onClick(item,index)
        }
    }
    render(){
        let {menus,index }=this.props
        return (
            <div className="tabBox absMiddle">
                {
                    menus.map((item,i)=>{
                        return (
                           <div onClick={e=>this.onClick(e,item,i)} key={'tabItem'+item.name} className={`tabItem absMiddle ${index==i?'active':''}`}>
                                {item.name}
                           </div>
                        )
                    })
                }
            </div>
        )
    }
}
export default tab;